package pl.koziolekweb.jqr.ui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;

public class WordPanel extends JPanel implements Target {

	private static final long serialVersionUID = 1L;

	private JTextArea readingArea = new JTextArea();

	public WordPanel() {
		buildBasics();
		buildElements();
		buildLayout();
	}

	private void buildElements() {
		readingArea.setBorder(LineBorder.createBlackLineBorder());
		readingArea.setFont(new Font("Monospace", Font.PLAIN, 40));
		readingArea.setLineWrap(true);
		readingArea.setEditable(false);
		readingArea.setWrapStyleWord(true);
		update("Java Quick Reader");
		add(readingArea);
	}

	private void buildLayout() {
		BorderLayout layout = new BorderLayout();
		layout.addLayoutComponent(readingArea, BorderLayout.CENTER);
		setLayout(layout);

	}

	private void buildBasics() {
		setBorder(LineBorder.createBlackLineBorder());
		setPreferredSize(new Dimension(790, 144));
	}

	public void update(String text) {
		readingArea.setText(text);
	}

	public void clean() {
		update("");
	}
}
